package 多线程;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author : K k
 * @date : 13:30 2020/9/30
 */
public class ThreadDemo implements Runnable {
    static volatile AtomicInteger count=new AtomicInteger(0);
    private String name;

    public ThreadDemo(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        try {
            count.set(count.get()+1);
            System.out.println("线程："+name+"的count为"+count.get());
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
